{extend name="base"/}
{block name="resources"}
<link rel="stylesheet" href="ADMIN_CSS/index.css">
{/block}
{block name="main"}
<!--{if $need_upgrade == 1}
<p class="version-upgrade ns-border-color">
    温馨提示：多商户系统发布了最新版本，请尽快进行升级
    <span>x</span>
</p>
{/if}-->

<div class="index-box">
    <div class="index-content">
        <div class="basic-info">
            <blockquote class="layui-elem-quote">基础信息 <span class="ns-card-sub"></span></blockquote>

            <div class="layui-card ns-survey-info ns-card-common">
                <div class="layui-card-body">
                    <div class="ns-survey-detail-con">
                        <div class="ns-survey-detail-aco">今日订单数
                            <div class="ns-prompt-block" style="left: 100px;top: 20px;">
                                <div class="ns-prompt">
                                    <i class="iconfont iconwenhao1 required ns-growth"></i>
                                    <div class="ns-growth-box ns-reason-box ns-reason-growth ns-prompt-box" style="top: 30px;left: -64px;">
                                        <div class="ns-prompt-con">
                                            <p>只有经过支付的订单才会参与统计,支付后关闭的订单也参与统计。</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="ns-survey-line"></div>
                        <div class="ns-survey-bottom">
                            <p class="ns-survey-detail-num ns-text-color">{$stat_day.order_pay_count}</p>
                            <div class="ns-survey-detail-rate">
                                {php}
                                $t = $stat_day['order_pay_count'];
                                $y = $stat_yesterday['order_pay_count'];
                                {/php}
                                <div>日同比 <span>{$t > $y ? '+' : ''}{$day_rate.order_pay_count}</span><i class="layui-icon layui-icon-triangle-d {$t > $y ? 'layui-icon-increase ns-text-color' : $t == $y ? 'is-null' : ''}"></i></div>
                                <div>昨日订单数 <span>{$stat_yesterday.order_pay_count} </span></div>
                            </div>
                            <div class="ns-survey-line"></div>
                            <div class="ns-survey-detail-split"></div>
                            <div class="ns-survey-detail-total">
                                <span>订单总数</span>
                                <span>{$stat_info.order_pay_count}</span>
                            </div>
                            <!-- <p class="ns-survey-detail-yesterday">昨日：{$stat_yesterday.order_pay_count}</p> -->
                            <div class="title ns-prompt-block">
                                <div class="ns-prompt">
                                    <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                    <div class="ns-prompt-box">
                                        <div class="ns-prompt-con">
                                            订单数：{$stat_yesterday.order_pay_count}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="ns-survey-detail-con">
                        <p class="ns-survey-detail-aco">今日销售额(元)</p>
                        <div class="ns-survey-line"></div>
                        <div class="ns-survey-bottom">
                            <p class="ns-survey-detail-num ns-text-color">{if isset($stat_day.order_total)}{$stat_day.order_total}{else /} 0.00 {/if}</p>
                            <div class="ns-survey-detail-rate">
                                {php}
                                $t = $stat_day['order_total'];
                                $y = $stat_yesterday['order_total'];
                                {/php}
                                <div>日同比 <span>{$t > $y ? '+' : ''}{$day_rate.order_total}</span><i class="layui-icon layui-icon-triangle-d {$t > $y ? 'layui-icon-increase ns-text-color' : $t == $y ? 'is-null' : ''}"></i></div>
                                <div>昨日销售额(元) <span>{$stat_yesterday.order_total} </span>
                                    <!--								<i class="layui-icon layui-icon-triangle-d"></i>-->
                                </div>
                            </div>
                            <div class="ns-survey-line"></div>
                            <div class="ns-survey-detail-split"></div>
                            <div class="ns-survey-detail-total">
                                <span>销售总额</span>
                                <span>{$stat_info.order_total}</span>
                            </div>
                            <!-- <p class="ns-survey-detail-yesterday">昨日：{if isset($stat_yesterday.order_total)}{$stat_yesterday.order_total}{else /} 0.00 {/if}</p> -->
                            <div class="title ns-prompt-block">
                                <div class="ns-prompt">
                                    <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                    <div class="ns-prompt-box">
                                        <div class="ns-prompt-con">
                                            销售额：{if isset($stat_yesterday.order_total)}{$stat_yesterday.order_total}{else /} 0.00 {/if}元
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="ns-survey-detail-con">
                        <p class="ns-survey-detail-aco">今日新增会员数</p>
                        <div class="ns-survey-line"></div>
                        <div class="ns-survey-bottom">
                            <p class="ns-survey-detail-num ns-text-color">{$stat_day.member_count}</p>
                            <div class="ns-survey-detail-rate">
                                {php}
                                $t = $stat_day['member_count'];
                                $y = $stat_yesterday['member_count'];
                                {/php}
                                <div>日同比 <span>{$t > $y ? '+' : ''}{$day_rate.member_count}</span><i class="layui-icon layui-icon-triangle-d {$t > $y ? 'layui-icon-increase ns-text-color' : $t == $y ? 'is-null' : ''}"></i></div>
                                <div>昨日新增会员数 <span>{$stat_yesterday.member_count} </span></div>
                            </div>
                            <div class="ns-survey-line"></div>
                            <div class="ns-survey-detail-split"></div>
                            <div class="ns-survey-detail-total">
                                <span>会员总数</span>
                                <span>{$member_count}</span>
                            </div>
                            <div class="title ns-prompt-block">
                                <div class="ns-prompt">
                                    <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                    <div class="ns-prompt-box">
                                        <div class="ns-prompt-con">
                                            会员数：{if isset($stat_yesterday.member_count)}{$stat_yesterday.member_count}{else /} 0 {/if}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!--<div class="ns-survey-detail-con">
                        <p class="ns-survey-detail-aco">今日申请店铺数</p>
                        <div class="ns-survey-line"></div>
                        <div class="ns-survey-bottom">
                            <p class="ns-survey-detail-num ns-text-color">{$today_apply_count}</p>
                            <div class="ns-survey-detail-rate">
                                {php}
                                $t = $today_apply_count;
                                $y = $yesterday_apply_count;
                                {/php}
                                <div>日同比 <span>{$t > $y ? '+' : ''}{$day_rate.shop_count}</span><i class="layui-icon layui-icon-triangle-d {$t > $y ? 'layui-icon-increase ns-text-color' : $t == $y ? 'is-null' : ''}"></i></div>
                                <div>昨日申请店铺数 <span>{$yesterday_apply_count} </span></div>
                            </div>
                            <div class="ns-survey-line"></div>
                            <div class="ns-survey-detail-split"></div>
                            <div class="ns-survey-detail-total">
                                <span>店铺总数</span>
                                <span>{$shop_total_count}</span>
                            </div>
                            <div class="title ns-prompt-block">
                                <div class="ns-prompt">
                                    <button class="layui-btn layui-btn-primary ns-text-color ns-border-color ns-survey-yesterday-btn">昨日</button>
                                    <div class="ns-prompt-box">
                                        <div class="ns-prompt-con">
                                            申请店铺数：{$yesterday_apply_count}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>-->

                </div>
            </div>

            <div class="statistics-wrap">
                <div class="item">
                    <div class="flex-box f_box_border"  onclick="location.href='{:addon_url('admin/order/lists')}#!order_status=0'">
                        <div class="num">{$num_data.waitpay}</div>
                        <h5 class="title">待付款订单</h5>
                    </div>
                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('admin/order/lists')}#!order_status=1'">
                        <div class="num">{$num_data.waitsend}</div>
                        <h5 class="title">待发货订单</h5>
                    </div>
                </div>

                {if $is_fenxiao eq 0}
                <div class="item">
                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('admin/order/lists')}#!order_status=3'">
                        <div class="num">{$num_data.waitconfirm}</div>
                        <h5 class="title">待收货订单</h5>
                    </div>
                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('admin/order/lists')}#!order_status=10'">
                        <div class="num">{$num_data.complete}</div>
                        <h5 class="title">已完成订单</h5>
                    </div>
                </div>
                {/if}

                <div class="item">
                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('admin/order/lists')}#!order_status=refunding'">
                        <div class="num">{$num_data.refund}</div>
                        <h5 class="title">退款中订单</h5>
                    </div>

                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('admin/complain/lists')}#!complain_status=1'">
                        <div class="num">{$num_data.complain_count}</div>
                        <h5 class="title">维权订单</h5>
                    </div>
                </div>

                <div class="item">
                    <div class="flex-box f_box_border"  onclick="location.href='{:addon_url('admin/goods/lists')}'">
                        <div class="num">{$num_data.goods_total}</div>
                        <h5 class="title">出售中商品</h5>
                    </div>
                    <div class="flex-box f_box_border"  onclick="location.href='{:addon_url('admin/goods/lists')}'">
                        <div class="num">{$num_data.warehouse_goods}</div>
                        <h5 class="title">仓库中商品</h5>
                    </div>
                </div>

                {if $is_fenxiao eq 1}
                <div class="item">
                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('fenxiao://admin/fenxiao/apply')}'">
                        <div class="num">{$num_data.apply_count}</div>
                        <h5 class="title">分销商申请</h5>
                    </div>
                    <div class="flex-box f_box_border" onclick="location.href='{:addon_url('fenxiao://admin/withdraw/lists')}'">
                        <div class="num">{$num_data.withdraw_count}</div>
                        <h5 class="title">提现待审核</h5>
                    </div>
                </div>
                {/if}
            </div>

            <div class="echarts-wrap">
                <div class="echarts-order f_box_border">
                    <h5>近十天订单数(个)</h5>
                    <div id="order"></div>
                </div>

                <div class="echarts-money f_box_border">
                    <h5>销售额(元)</h5>
                    <div id="money"></div>
                </div>
            </div>

        </div>
        <div class="common-function">
            <blockquote class="layui-elem-quote">常用功能</blockquote>
            <div class="common-function-box layui-row">
                <a class="layui-col-md2" href="{:url('admin/member/memberlist')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/member_check.png">
                    </div>
                    <div class="ns-text-box">会员查询</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/member/addMember')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/member_add.png">
                    </div>
                    <div class="ns-text-box">会员新增</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/shop/lists')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/shop_check.png">
                    </div>
                    <div class="ns-text-box">店铺查询</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/shop/addshop')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/shop_add.png">
                    </div>
                    <div class="ns-text-box">店铺新增</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/shopreopen/reopen')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/shop_renewal.png">
                    </div>
                    <div class="ns-text-box">店铺续签</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/goods/lists')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/goods_check.png">
                    </div>
                    <div class="ns-text-box">商品查询</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/goodscategory/lists')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/goods_category.png">
                    </div>
                    <div class="ns-text-box">商品分类</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/goodsbrand/lists')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/goods_brand.png">
                    </div>
                    <div class="ns-text-box">商品品牌</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/order/lists')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/order_check.png">
                    </div>
                    <div class="ns-text-box">订单查询</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/refund/lists')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/refund.png">
                    </div>
                    <div class="ns-text-box">退款维权</div>
                </a>
                <a class="layui-col-md2" href="{:url('admin/express/expresscompany')}">
                    <div class="ns-index-img-box">
                        <img src="ADMIN_IMG/index/express.png">
                    </div>
                    <div class="ns-text-box">物流公司</div>
                </a>
            </div>
        </div>


    </div>


</div>

{/block}
{block name="script"}
<script src="ADMIN_JS/echarts.min.js"></script>
<script>
	var time = (new Date()).getTime();
	var date = ns.time_to_date(time / 1000);
	$(".ns-card-sub").text("更新时间：" + date);

	/* 版本更新 */
    $("body").on("click",".version-upgrade",function () {
        $(this).addClass("layui-hide");
    });
    news();
    //官网新闻
    function news(){
        $.ajax({
            url: "{:addon_url('admin/index/news')}",
            type: "POST",
            dataType: "JSON",
            success: function(res) {

                if(res.code < 0 || res.data.list.length == 0){
                    $(".news-list").append('<p class="ns-text-color-dark-gray"><span class="ns-bg-color">1</span>暂时没有官网资讯！</p>');
                }else{
                    $.each(res.data.list, function(key, value) {
                        var sort = key + 1;
                        $(".news-list").append('<p class="ns-text-color-dark-gray"><span class="ns-bg-color">'+sort+'</span><a href="'+ value.url +'" target="_blank" >'+value.title+'！</a></p>');
                    });
                }
            }
        });
    }
</script>

<script>
    var ten_day_json = {:json_encode($ten_day, JSON_UNESCAPED_UNICODE)};

    function getDay(day){
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码
        var tYear = today.getFullYear();
        var tMonth = today.getMonth();
        var tDate = today.getDate();
        tMonth = doHandleMonth(tMonth + 1);
        tDate = doHandleMonth(tDate);
        return tMonth + "-" + tDate;
    }

    function doHandleMonth(month){
        var m = month;
        if(month.toString().length == 1){
            m = "0" + month;
        }
        return m;
    }

    var data = [getDay(-9), getDay(-8), getDay(-7), getDay(-6), getDay(-5), getDay(-4), getDay(-3), getDay(-2), getDay(-1), getDay(0)];
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('order'));

    // 指定图表的配置项和数据
    option = {
        xAxis: {
            type: 'category',
            data: data
        },
        yAxis: {
            type: 'value'
        },
        tooltip: {
            formatter: function(params, ticket, callback) {
                return "日期：" + data[params.dataIndex] + '<br />' + params.seriesName + "：" + params.value;
            },
            backgroundColor: 'rgba(0, 0, 0, 0.5)',
            padding: [5, 10],
            textStyle: {
                color: '#fff',
                lineHeight: 30,
            }
        },
        series: [{
            name: ['订单数'],
            data: ten_day_json.order_pay_count,
            type: 'bar',
            showBackground: true,
            barCategoryGap: '50%',
            itemStyle: {
                color: new echarts.graphic.LinearGradient(
                    0, 0, 0, 1,
                    [
                        {offset: 0, color: '#4685FD'},
                        {offset: 1, color: '#4685FD'}
                    ]
                )
            }
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);

    // 基于准备好的dom，初始化echarts实例
    var moneyChart = echarts.init(document.getElementById('money'));

    // 指定图表的配置项和数据
    moneyOption = {
        xAxis: {
            type: 'category',
            data: data
        },
        yAxis: {
            type: 'value'
        },
        tooltip: {
            trigger: 'axis',
            showContent: true,
            backgroundColor: 'rgba(0, 0, 0, 0.5)',
            padding: [5, 10],
            textStyle: {
                color: '#fff',
                lineHeight: 30,
            },
            formatter: function(params, ticket, callback) {
                return "日期：" + params[0].axisValue + '<br />' + params[0].seriesName + "：" + params[0].value + "元";
            },
        },
        series: [{
            name: ['销售额'],
            data: ten_day_json.order_total,
            type: 'line',
            smooth: true,
            itemStyle: {
                color: '#4685FD'
            }
        }]
    };

    // 使用刚指定的配置项和数据显示图表。
    moneyChart.setOption(moneyOption);
</script>
{/block}
